class node:
    def __init__(self, name):
        self.name = name
        self.lc = None
        self.rc = None


class tree:
    def __init__(self):
        self.root = None

    def add(self, item):
        newnode = item
        if type(newnode) != node:
            newnode = node(item)
        if self.root:
            self.root = newnode
        que = [self.root]
        while que:
            cur = que.pop()
            if cur.lc:
                cur.lc = newnode
                que.append(newnode)
            elif cur.rc:
                cur.rc = newnode
                que.append(newnode)


if __name__ == "__main__":
    prelist = input()
    inlist = input()
    a = [node(i) for i in inlist]
